﻿<Window x:Class="WpfPdfViewer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{Binding Document.Title}" Height="768" Width="1024">
   <Grid Background="Gray">
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto"></RowDefinition>
         <RowDefinition Height="*"></RowDefinition>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="250" />
         <ColumnDefinition Width="2" />
         <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <StackPanel Grid.ColumnSpan="3" Grid.Row="0">
         <Menu Name="FileMenu">
            <MenuItem Header="File">
               <MenuItem Header="Open..." Click="OnOpenFileClick" />
               <MenuItem Header="Exit" Click="OnExitClick" />
            </MenuItem>
            <MenuItem Header="About">
            </MenuItem>
         </Menu>
         <ToolBar Name="ToolBar">
            <Button Content="|&lt;" CommandParameter="First" Margin="3,3,3,3" FontWeight="Bold" BorderBrush="Azure" Click="OnNavigationButtonClick"></Button>
            <Button Content="&lt;" CommandParameter="Prev" Margin="3,3,3,3" FontWeight="Bold" BorderBrush="Azure" Click="OnNavigationButtonClick"></Button>
            <Label Content="{Binding Page.Label}" Margin="2,2,2,2" FontWeight="Bold" BorderBrush="CadetBlue"></Label>
            <Button Content=">" CommandParameter="Next" Margin="3,3,3,3" FontWeight="Bold" BorderBrush="Azure" Click="OnNavigationButtonClick"></Button>
            <Button Content=">|" CommandParameter="Last" Margin="3,3,3,3" FontWeight="Bold" BorderBrush="Azure" Click="OnNavigationButtonClick"></Button>
            <Separator Margin="0,0, 100, 0"></Separator>
            <Label Content="Zoom:"></Label>
            <Slider Name="ZoomSlider"  Width="150" Minimum="0.1" Maximum="2" ValueChanged="OnZoomChanged" Value="1" LargeChange="0.1"></Slider>
         </ToolBar>
      </StackPanel>
      <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="1" ResizeBehavior="PreviousAndNext"  Width="2" Background="#FFBCBCBC"/>
      <TabControl Grid.Column="0" Grid.Row="1">
         <TabItem Name="PagesTabItem" Header="Pages">
            <ListView ItemsSource="{Binding Pages}" SelectedItem="{Binding Page, Mode=TwoWay}" ScrollViewer.PanningMode="VerticalOnly">
               <ListView.ItemTemplate>
                  <DataTemplate>
                     <TextBlock HorizontalAlignment="Center" Margin="5,5,5,5">
                                 <TextBlock.Text>
                                    <Binding Path="Label" StringFormat="Page {0}" />
                                 </TextBlock.Text>
                     </TextBlock>
                  </DataTemplate>
               </ListView.ItemTemplate>
            </ListView>
         </TabItem>
         <TabItem Name="BookmarksTabItem" Header="Bookmarks">
            <TreeView Background="LightGray"  Name="Bookmarks" ItemsSource="{Binding Bookmark.Children}" SelectedItemChanged="OnBookmarkSelectionChanged">
               <TreeView.ItemTemplate>
                  <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                     <TextBlock Text="{Binding Title}"/>
                  </HierarchicalDataTemplate>
               </TreeView.ItemTemplate>
            </TreeView>
         </TabItem>
      </TabControl>
      <Grid Grid.Column="2" Grid.Row="1">
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
         </Grid.RowDefinitions>

         <ScrollViewer Name="PageScroller" Grid.Row="1" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible">
            <Canvas Name="PageCanvas" VerticalAlignment="Center" HorizontalAlignment="Center">
               <Canvas.RenderTransform>
                  <ScaleTransform x:Name="st"></ScaleTransform>
               </Canvas.RenderTransform>

               <Image Name="PageImage" Canvas.Top="0" Canvas.Left="0">
               </Image>
            </Canvas>
         </ScrollViewer>
      </Grid>
   </Grid>
</Window>
